package com.kemang.Girl;

public class GF_test {
    public static void main(String[] args) {
        GirlFriend[] girlFriends=new GirlFriend[4];
        GirlFriend girlFriend1=new GirlFriend("小张",18,'女',"打篮球");
        GirlFriend girlFriend2=new GirlFriend("小李",19,'女',"打乒乓球");
        GirlFriend girlFriend3=new GirlFriend("小王",21,'女',"踢足球");
        GirlFriend girlFriend4=new GirlFriend("小黄",22,'女',"听音乐");
        girlFriends[0]=girlFriend1;
        girlFriends[1]=girlFriend2;
        girlFriends[2]=girlFriend3;
        girlFriends[3]=girlFriend4;
        double average_age=age_avg(girlFriends);
        count(girlFriends,average_age);
    }
    public static double age_avg(GirlFriend[] girlFriends){
        double sum=0;
        for (int i = 0; i < girlFriends.length; i++) {
            sum+=girlFriends[i].getAge();
        }
        double average=sum/ girlFriends.length;
        return average;
    }
    public static void count(GirlFriend[] girlFriends,double avg){
        int count=0;
        for (int i = 0; i < girlFriends.length; i++) {
            if (girlFriends[i].getAge()<avg){
                count++;
                System.out.println("这是第"+(i+1)+"个"+" "+girlFriends[i].getName()+" "+girlFriends[i].getAge()
                +" "+girlFriends[i].getHobby());
            }
        }
        System.out.println("一共"+count+"个");
    }
}
